/*
 * utf8stringobject.h
 *
 *  Created on: Nov 3, 2009
 *  Author: Silviu Caragea
 */

#ifndef UTF8MAPOBJECT_H_
#define UTF8MAPOBJECT_H_

#include "mapobject.h"
#include "intnumberobject.h"
#include "smartpointers/yasper.h"
#include <map>
#include <vector>

namespace templatipus
{
	 class TUtf8MapObject: public TMapObject
	 {

protected:
		std::map<std::string,yasper::ptr<TemplateObject> > internalMap;

 public:
		//constructor && destructor
		TUtf8MapObject();
		TUtf8MapObject(const TemplateObject &other);
		TUtf8MapObject(const int8 &rhs);
		TUtf8MapObject(const int16 &rhs);
		TUtf8MapObject(const int32 &rhs);
		TUtf8MapObject(const int64 &rhs);
		TUtf8MapObject(const float32 &rhs);
		TUtf8MapObject(const float64 &rhs);
		TUtf8MapObject(const std::wstring& rhs);
		TUtf8MapObject(const std::string& rhs);
		TUtf8MapObject(const utf8Ptr rhs);
		TUtf8MapObject(const unicodePtr rhs);

		virtual ~TUtf8MapObject();

		//properties
		virtual TIntNumberObject getLength() const;

		//methods
		virtual void clear();
		virtual tbool isEmpty() const;
		virtual int64 size() const;

		virtual tbool equals(const TemplateObject &object) const;
		virtual std::vector<std::string> getKeySet() ;
		virtual tbool containsKey(const std::string &key) ;

		virtual tbool add(const std::string &key, const TemplateObject &object);
		virtual void remove(const std::string & key);

		virtual TemplateObject & getObject(const std::string & key);
		virtual tbool containsValue(const TemplateObject & object);
		virtual std::vector<TemplateObject> values();
		virtual void putAll(const TemplateObject & other);

		//operators

		virtual const TemplateObject& operator +=(const TemplateObject &other);
		TUtf8MapObject operator +(const TUtf8MapObject &other);

		//assigning values
		virtual TemplateObject& operator=(const TemplateObject &other);
		virtual TemplateObject& operator=(const int8 &other);
		virtual TemplateObject& operator=(const int16 &other);
		virtual TemplateObject& operator=(const int32 &other);
		virtual TemplateObject& operator=(const int64 &other);
		virtual TemplateObject& operator=(const float32 &other);
		virtual TemplateObject& operator=(const float64 &other);
		virtual TemplateObject& operator=(const std::wstring& other);
		virtual TemplateObject& operator=(const std::string& other);
		virtual TemplateObject& operator=(const utf8Ptr other);
		virtual TemplateObject& operator=(const unicodePtr other);

		//comparison
		virtual tbool operator ==(const TemplateObject &other) const;
		virtual tbool operator !=(const TemplateObject &other) const;

		virtual const TemplateObject& operator [](const uint64 index);
		virtual const TemplateObject& operator [](const utf8Ptr key);
		virtual const TemplateObject& operator [](const unicodePtr key);
		virtual const TemplateObject& operator ()(const utf8Ptr key,const TemplateObject &params);
		virtual const TemplateObject& operator ()(const unicodePtr key,	const TemplateObject &params);

		//String stuff
		virtual operator std::string() const;
		virtual operator std::wstring() const;

		//Conversion operators
		//Number
		virtual operator tbool() const;
		virtual operator int8() const;
		virtual operator uint8() const;
		virtual operator int16() const;
		virtual operator uint16() const;
		virtual operator int32() const;
		virtual operator uint32() const;
		virtual operator int64() const;
		virtual operator uint64() const;
		virtual operator float32() const;
		virtual operator float64() const;

		virtual TemplateObject * newInstance() const {return new TUtf8MapObject();}

	 };

}

#endif /* UTF8MAPOBJECT_H_ */
